package openAStage;

import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

import java.io.IOException;

/**
 * @auther: Liu Zedi.
 * @date: Create in 2018/9/5  15:33
 * @package: openAStage
 * @project: Dictionary
 */
public class openTestStage {

    public static void openIt(Stage testStage,String urlFXML,String urlCSS){
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                FXMLLoader fxmlLoader=new FXMLLoader(getClass().getResource(urlFXML));

                try {

                    AnchorPane pane=(AnchorPane)fxmlLoader.load();
                    Scene scene=new Scene(pane);
                    scene.getStylesheets().add(
                            getClass().getResource(urlCSS)
                                    .toExternalForm());
                    testStage.setScene(scene);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
    }
}
